package com.sanbi.erp.db.util;

import com.github.houbb.property.bs.PropertyBs;
import com.sanbi.erp.core.config.UserConfig;

import java.util.ArrayList;
import java.util.List;

/**
 * @introduce: 分销账单服务工具包(淘金币账单)
 * @Date: 2022/8/15 14:25
 * @Author: XYP
 */
public class DistributeBillUtil {

    public static final Short DB_TYPE_ONE = 1;
    public static final Short DB_TYPE_TWO = 2;
    public static final Short DB_TYPE_THREE = 3;
    public static final Short DB_TYPE_FOUR = 4;
    public static final Short DB_TYPE_FIVE = 5;
    public static final Short DB_TYPE_SIX = 6;
    public static final Short DB_TYPE_SEVEN = 7;
    public static final Short DB_TYPE_EIGHT = 8;
    public static final Short DB_TYPE_NINE = 9;
    public static final Short DB_TYPE_TEN = 10;

    /**
     * type = 1 ：分销收入
     * type = 2 ：分销退款
     * type = 3 ：分销退货退款
     * type = 4 ：转账支出
     * type = 5 ：转账收入
     * type = 6 ：购物
     * type = 7 ：提现
     * type = 8 ：退款
     * type = 9 ：退货退款
     */
    public static final String DB_DISC_ONE;
    public static final String DB_DISC_TWO;
    public static final String DB_DISC_THREE;
    public static final String DB_DISC_FOUR;
    public static final String DB_DISC_FIVE;
    public static final String DB_DISC_SIX;
    public static final String DB_DISC_SEVEN;
    public static final String DB_DISC_EIGHT;
    public static final String DB_DISC_NINE;

    // 下拉项
    public static final String DB_TYPES_ZERO;
    public static final String DB_TYPES_ONE;
    public static final String DB_TYPES_TWO;
    public static final String DB_TYPES_THREE;
    public static final String DB_TYPES_FOUR;
    public static final String DB_TYPES_FIVE;
    public static final String DB_TYPES_SIX;
    public static final String DB_TYPES_SEVEN;
    public static final String DB_TYPES_EIGHT;
    public static final String DB_TYPES_NINE;

    // 等...
    public static final String DB_DISC_Desc;

    static {
        UserConfig userConfig = new UserConfig();
        PropertyBs.getInstance("user.properties").asBean(userConfig);
        DB_DISC_ONE = userConfig.getDbDiscOne();
        DB_DISC_TWO = userConfig.getDbDiscTwo();
        DB_DISC_THREE = userConfig.getDbDiscThree();
        DB_DISC_FOUR = userConfig.getDbDiscFour();
        DB_DISC_FIVE = userConfig.getDbDiscFive();
        DB_DISC_SIX = userConfig.getDbDiscSix();
        DB_DISC_SEVEN = userConfig.getDbDiscSeven();
        DB_DISC_EIGHT = userConfig.getDbDiscEight();
        DB_DISC_NINE = userConfig.getDbDiscNine();

        DB_DISC_Desc = userConfig.getDbDiscDesc();

        DB_TYPES_ZERO = userConfig.getDbTypeZero();
        DB_TYPES_ONE = userConfig.getDbTypeOne();
        DB_TYPES_TWO = userConfig.getDbTypeTwo();
        DB_TYPES_THREE = userConfig.getDbTypeThree();
        DB_TYPES_FOUR = userConfig.getDbTypeFour();
        DB_TYPES_FIVE = userConfig.getDbTypeFive();
        DB_TYPES_SIX = userConfig.getDbTypeSix();
        DB_TYPES_SEVEN = userConfig.getDbTypeSeven();
        DB_TYPES_EIGHT = userConfig.getDbTypeEight();
        DB_TYPES_NINE = userConfig.getDbTypeNine();
    }

    /**
     * 根据类型获取对应的描述
     * 用来作为查询条件
     *
     * @param type 类型
     * @return
     */
    public static String getTypeDesc(Short type) {
        String typeDesc = null;
        // 1 分销收入，2 分销退款，3 分销退货退款，4 转账支出，5 转账收入，6 购物，7 提现，8 退款，9 退货退款
        if (type.equals(DB_TYPE_ONE)) typeDesc = DB_TYPES_ONE;
        if (type.equals(DB_TYPE_TWO)) typeDesc = DB_TYPES_TWO;
        if (type.equals(DB_TYPE_THREE)) typeDesc = DB_TYPES_THREE;
        if (type.equals(DB_TYPE_FOUR)) typeDesc = DB_TYPES_FOUR;
        if (type.equals(DB_TYPE_FIVE)) typeDesc = DB_TYPES_FIVE;
        if (type.equals(DB_TYPE_SIX)) typeDesc = DB_TYPES_SIX;
        if (type.equals(DB_TYPE_SEVEN)) typeDesc = DB_TYPES_SEVEN;
        if (type.equals(DB_TYPE_EIGHT)) typeDesc = DB_TYPES_EIGHT;
        if (type.equals(DB_TYPE_NINE)) typeDesc = DB_TYPES_NINE;
        // 0 全部账单
        if (type == 0) typeDesc = null;
        return typeDesc;
    }

    /**
     * 获取分销账单下拉条件
     *
     * @return
     */
    public static List<String> getTypeAll() {
        List<String> list = new ArrayList<>();
        list.add(DB_TYPES_ZERO);
        list.add(DB_TYPES_ONE);
        list.add(DB_TYPES_TWO);
        list.add(DB_TYPES_THREE);
        list.add(DB_TYPES_FOUR);
        list.add(DB_TYPES_FIVE);
        list.add(DB_TYPES_SIX);
        list.add(DB_TYPES_SEVEN);
        list.add(DB_TYPES_EIGHT);
        list.add(DB_TYPES_NINE);
        return list;
    }

}
